﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESOL.WinUI.BaseForm;

namespace ESOL.WinUI.BaseForm
{
    public partial class frmBaseMdiParentForm : frmBaseForm
    {
        public frmBaseMdiParentForm()
        {
            InitializeComponent();
        }

        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            foreach (Form frmOpen in this.MdiChildren)
            {
                frmOpen.Close();
                frmOpen.Dispose();
            }
            base.OnFormClosing(e);
        }

        private DateTime m_LastClick = System.DateTime.Now;
        private void xtraTabbedMdiManager1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                DateTime dt = DateTime.Now;
                TimeSpan span = dt.Subtract(m_LastClick);
                if (span.TotalMilliseconds < 300)  //如果两次点击的时间间隔小于300毫秒，则认为是双击
                {
                    if (this.MdiChildren.Length > 1)
                    {
                        //if (this.ActiveMdiChild != m_MapForm)
                        //{
                            this.ActiveMdiChild.Close();
                        //}
                    }
                    m_LastClick = dt.AddMinutes(-1);
                }
                else
                {
                    m_LastClick = dt;
                }
            }
            //else if (e.Button == MouseButtons.Right)
            //{
            //    //弹出右键菜单
            //    if (this.ActiveMdiChild != m_MapForm)
            //    {
            //        POINTAPI pt = new POINTAPI();
            //        GetCursorPos(ref pt);
            //        System.Drawing.Point p = new System.Drawing.Point(pt.x, pt.y);
            //        popMenuCloseTab.ShowPopup(this.barManager1, p);
            //    }
            //}
        }
    }
}
